<?php $this->load->view('qt/header'); ?>


<!--  PAPER WRAP -->
<div class="wrap-fluid">
    <div class="container-fluid paper-wrap bevel tlbr">

        <!-- CONTENT -->
        <!--TITLE -->
        <div class="row">
            <div id="paper-top">
                <div class="col-sm-12">
                    <h2 class="tittle-content-header">
                        <i class="qt-network"></i>
                        <span id="title-header">
                            <?php echo (isset($this->title_header)) ? $this->title_header : 'CHI TIẾT CÔNG TY';?>
                        </span>
                    </h2>
                </div>
            </div>
        </div>
        <!--/ TITLE -->
        <ul id="breadcrumb">
            <li><span class="entypo-home"></span></li>
            <li><i class="fa fa-lg fa-angle-right"></i></li>
            <li><a href="#main">Trang chủ</a></li>
        </ul>
        <div class="content-wrap"  style="margin-top: 10px; height: 900px;">

 <?php
$rs=$this->model_companies->selectDetail(array("cust_creator_id"=>$this->session->userdata('uId'),"array_uId"=>$this->data["array_parent_id"],'comp_id'=>$this->data["result"]["comp_conflict_id"]));
if(count($rs)>0){
	$rs=$rs[0];
}



$n=0;
$array=array('comp_tax_code','comp_name','comp_address','comp_phone','comp_bank_account','comp_img_verify','comp_img_tax');
foreach($array as $v){
	if($this->data["result"][$v]!=""){
		$n+=1;
	}
}

$color="danger";
$px=round($n/(count($array))*100);

?>

<section class="vbox" id="detail_customer">
	<section class="scrollable">
		<section class="hbox stretch">
			<aside class="col-lg-4 bg-light lter b-r" style="padding-right: 0px !important;">
				<section class="vbox">
					<section class="scrollable">
						<div class="wrapper">
							<section class="panel no-border bg-bla lt">
								<div class="panel-body" style="padding: 0px !important;">
									<div class="row m-t-xl" style="padding: 0px !important; margin: 0px !important;">
										<div class="col-xs-12 text-center" style="padding: 0px !important;">
                                            <header class="qth" style="font-size: 12px; 
                                                            font-weight: bold;
                                                            border: 1px solid #bcbcbc;
                                                            width: 100%;
                                                            height: 35px;
                                                            padding-top: 6px;">Thông tin cá nhân</header>
											<div class="" style="border: 1px solid #bcbcbc;
                                                                 border-top: none;"><!-- inline -->
												<div  style="width: 140px; height: 140px; line-height: 140px;margin: 0 auto;">
													<div class="thumb-lg avatar">
														<img src="<?php echo base_url();?>/images/avatar.png" class="dker">
													</div>
													<canvas width="140" height="140" style="display: none;"></canvas>
													<input type="hidden" value="<?php echo $_REQUEST["id"]?>" id="cust_id"/>
												</div>
												<p style="padding-right: 5px;
                                                       font-size: 16px;">
													   <div class="text-lt font-bold pointer editable editable-click" id="dt_comp_name" data="comp_name">
													   <?php echo $this->data["result"]["comp_name"];?>
													   </div>
                                                       </p>
                                                <p style="color: #ff6700;">
                                                <?php echo ucfirst(strtolower($this->data["result"]["comp_address"]));?></p>
											</div>

											<div class="row m-t-lg">
											<div class="col-xs-6 col-xs-offset-3 text-center">
												<small style="color: #ff6700;">Tình trạng</small>
												<div class="text-lt font-bold">

												<div class="row m-t-lg">
														<div class="col-xs-6 col-xs-offset-3 text-center">
															<small>Tình trạng</small>
															<div class="text-lt font-bold">
																<?php if($this->fclass->check_permission('special','is_accounting',$this->session->userdata('permissions2'),$this->session->userdata('permissions_base'))){
													?>
																<form action="" method="POST" class="form_verify">
																	<input type="hidden" name="mod" value="verify">
																	<?php 
																	if($this->data["result"]["comp_status"]==-2){
																		echo '<button type="button" class="btn btn-warning btn-s-lg">Đang bị confLict</button>';
																	}else if($this->data["result"]["comp_status"]==0){
																		if($px<100){
																			echo '<button type="button" onclick="viewMsg(\'Vui lòng cập nhật đầy đủ thông tin mới được xác nhận.<br/> Thông tin đang đã được cập nhật '.$px.'%\')" class="btn btn-danger btn-s-lg">Chưa xác nhận</button>';
																		}else{
																			echo '<button type="button" onclick="validate_verify()" class="btn btn-danger btn-s-lg">Chưa xác nhận</button>';
																		}

																	}else if($this->data["result"]["comp_status"]==1){
																		echo '<button type="button" class="btn btn-primary btn-s-lg">Đã Xác Nhận</button>';
																	}else{

																	}
																	?>
																</form>
																<?php }else{
																	if($this->data["result"]["comp_status"]==-2){
																		echo '<span class="label bg-warning">Đang bị confLict</span>';
																	}else if($this->data["result"]["comp_status"]==0){
																		
																			echo '<span class="label bg-danger btn-s-lg">Chưa xác nhận</span>';
																		

																	}else if($this->data["result"]["comp_status"]==1){
																		echo '<span class="label bg-success">Đã Xác Nhận</span>';
																	}else{

																	}

																	}	?>
															</div>
														</div>
													</div>

												<?php 
											// SET KETOAN MOI NHIN THAY
												if($this->fclass->check_permission('special','is_accounting',$this->session->userdata('permissions2'),$this->session->userdata('permissions_base'))&&count($rs)>0){
													?>
													<div class="btn-group"> 												
														<a href="#" class="btn btn-info btn-icon border-radius m-t-xl"  data-toggle="dropdown">
															<i class="i  i-settings text"></i> 
														</a>												
														<ul class="dropdown-menu pull-right"> 
															<li><a href="javascript:removeComp()"><i class="i i-trashcan"></i> Xóa</a></li>
															<!--	<li><a href="#"><i class="fa fa-check"></i> Xác nhận công ty là mới</a></li> -->													
														</ul> 
													</div>
													<?php }?>

												</div>
											</div>
											<div class="wrapper m-t m-b">
												<input type="hidden" id="comp_id" value="<?php echo $_REQUEST["id"]?>">
												<div class="row m-b">
													<div class="col-xs-6 text-right"> <small>Đại diện Pháp lý</small>
														<div class="text-lt font-bold pointer editable editable-click" id="dt_ceo_name" data="comp_ceo_name"><?php echo $this->data["result"]["comp_ceo_name"]?></div>
														
													</div>
													<div class="col-xs-6"> <small>Mã số thuế</small>
														<div class="text-lt font-bold pointer editable editable-click" id="dt_tax_code" data="comp_tax_code"><?php echo $this->data["result"]["comp_tax_code"]?> </div>
													</div>
												</div>
												<div class="row">
													<div class="col-xs-6 text-right"> <small>Số điện thoại</small>
														<div class="text-lt font-bold pointer editable editable-click" id="dt_phone" data="comp_phone"><?php echo $this->data["result"]["comp_phone"]?> </div>
													</div>
													<div class="col-xs-6"> <small>Tài khoản ngân hàng</small>
														<div class="text-lt font-bold pointer editable editable-pre-wrapped editable-click" id="dt_bank" data-type="textarea" data="comp_bank_account"><?php echo $this->data["result"]["comp_bank_account"]?>  </div>
													</div>
												</div>

												
													
													
												
												<?php  if($this->data["result"]["comp_status"]==-2){ ?>
												<div class="row m-t-lg">
													<div class="col-xs-6 col-xs-offset-3 text-center">
														<small>ConfLict Với Doanh Nghiệp</small>
														<div class="text-lt font-bold">													
															<a href="<?php echo base_url()."companies/detail?id=".$rs["comp_id"]?>" title="<?php echo $rs["comp_name"]?>"><?php echo $rs["comp_name"]?></a>
														</div>
													</div>
												</div>
												<?php } ?>
											</div>
										</div>
										<footer class="panel-footer dk text-center no-border">
											<div class="row pull-out">
												<div class="col-xs-4">
													<div class="padder-v"> <span class="m-b-xs h3 block text-white"><?php echo count($this->data["result_cust"]);?></span>  <small class="text-muted">Người đại diện</small>
													</div>
												</div>
												<div class="col-xs-4 dker">
													<div class="padder-v"> <span class="m-b-xs h3 block text-white"><?php echo $this->data["result"]["comp_rate"]?></span>  <small class="text-muted">Rating</small>
													</div>
												</div>
												<div class="col-xs-4">
													<div class="padder-v"> <span class="m-b-xs h3 block text-white">....</span>  <small class="text-muted"></small>
													</div>
												</div>
											</div>
										</footer>
									</section>
								</div>
							</section>
						</section>
					</aside>
					<aside class="col-lg-6 b-l no-padder">
						<section class="vbox">
							<section class="scrollable">
								<div class="wrapper portlet">
									<section class="panel panel-warning portlet-item">
										<header class="panel-heading">Hình ảnh Công ty</header>
										<div class="row">
											<div class="col-lg-12">
												<ul class="list-inline" id="img_verify_result" style="padding: 15px 15px 0;">
													<?php
													$imageUpload = json_decode($this->data["result"]["comp_img_verify"],true);
													if(count($imageUpload)>0){
														foreach($imageUpload as $num=> $val){
															echo '<li class="im_verify_'.$num.'">
															<a href="'.$val.'" class="thumbnail fancybox"><img src="'.$val.'" style="width:150px;height:120px;"></a>
															<span class="img-remove" onclick="remove_img_verify('.$_REQUEST["id"].','.$num.');"><i class="fa fa-times"></i></span>
															</li>';
														}
													}										
													?>
												</ul>
											</div>
										</div>
										<div class="row">
											<div class="col-lg-11 col-lg-offset-1">
												<div id="img_comp"></div>
											</div>
										</div>
									</section>
									<section class="panel panel-danger portlet-item">
										<header class="panel-heading">Hình ảnh Chứng từ Thuế</header>
										<div class="row">
											<div class="col-lg-12">
												<ul class="list-inline" id="img_tax_result" style="padding: 15px 15px 0;">
													<?php
													$imageUpload = json_decode($this->data["result"]["comp_img_tax"],true);
													if(count($imageUpload)>0){
														foreach($imageUpload as $num=> $val){
															echo '<li class="im_tax_'.$num.'">
															<a href="'.$val.'" class="thumbnail fancybox"><img src="'.$val.'" style="width:150px;height:120px;"></a>
															<span class="img-remove" onclick="remove_img_tax('.$_REQUEST["id"].','.$num.');"><i class="fa fa-times"></i></span>
															</li>';
														}
													}
													?>
												</ul>
											</div>
										</div>
										<div class="row">
											<div class="col-lg-11 col-lg-offset-1">
												<div id="img_tax"></div>
											</div>
										</div>
									</section>
									<section class="panel panel-default" id="progressbar">
										<header class="panel-heading"><strong>Người Đại Diện</strong>
											<!-- <div class="row m-t-sm">
												<div class="col-sm-8 m-b-xs">													
													<div class="btn-group">
													    <button type="button" class="btn btn-sm btn-default" onclick="selectContact(0)" title="Refresh"><i class="fa fa-refresh"></i></button>
													</div>
													<a href="http://develop.altamedia.vn:8990/partner/contact/form_add?comp_id=1" data-toggle="ajaxModal" class="btn btn-sm btn-default"><i class="fa fa-plus"></i> Thêm Người Đại Diện</a> 
												</div>
												<div class="col-sm-4 m-b-xs">
													<div class="input-group"> <input onkeyup="selectContact(0)" type="text" class="input-sm form-control" placeholder="Search" name="contact_search"> <span class="input-group-btn"> <button class="btn btn-sm btn-default" type="button">Tìm!</button> </span> </div>
												</div>
											</div>
											-->
											
										</header>
										<table class="table table-striped m-b-none">
											<thead>
												<tr>
													<th>Họ tên</th>
													<th width="150px">Thông tin</th>
													<th width="100px">Tình trạng</th>
													<th width="100px">Tài khoản</th>
												</tr>
											</thead>
											<tbody>
												<?php
												foreach($this->data["result_cust"] as $val){
													$n=0;
													$array=array('cust_first_name','cust_last_name','cust_tax_code','cust_address','cust_phone','cust_email','cust_dob','cust_bank_account','cust_cmnd','cust_cmnd_date','cust_cmnd_images','cust_sex');
													foreach($array as $v){
														if($val[$v]!=""){
															$n+=1;
														}
													}
													$color="danger";
													$px=round($n/(count($array))*100);
													if($px>=100){
														$color="success";
													}else if($px>=50){
														$color="warning";
													}
													?>

													<tr>
														<td><a href="<?php echo base_url()?>customer/detail?id=<?php echo $val["cust_id"]?>"><?php echo $val['cust_first_name'].' '.$val['cust_last_name'];?></a></td>
														<td>
															<div class="progress m-b-none progress-striped active"> <div class="progress-bar bg-<?php echo $color?>" data-toggle="tooltip" data-original-title="<?php echo $px?>%" style="width: <?php echo $px?>%"><?php echo $px?> %</div> </div>
														</td>
														<td><a href="<?php echo base_url()?>customer/detail?id=<?php echo $val["cust_id"]?>">
															<?php 
															if($val["cust_status"]==0){
																echo '<span class="label bg-danger">Chưa xác nhận</span>';
															}else if($val["cust_status"]==-2){
																echo '<span class="label bg-warning">Đang xử lý</span>';
															}else if($val["cust_status"]==1){
																echo '<span class="label bg-success">Đã xác nhận</span>';
															}else{
																echo '<span class="label bg-danger">Chưa xác nhận</span>';
															}

															?>
														</a></td>
														<td class="text-center">
															<?php 
															if($val["cust_username"]!=""){
																echo '<span class="label bg-success">'.$val["cust_username"].'</span>';
															}else{
																?>
																<button class="btn btn-primary btn-xs btn_create_acc" rel="<?php echo $val['cust_id']?>">Yêu cầu Tạo TK</button>
																<?php
															}
															?>
														</td>
													</tr>
													<?php
												}
												?>
											</tbody>
										</table>
									</section>
								</div>
							</section>
						</section>
					</aside>
				</section>
			</section>
		</section>
        
</div>
<div class="content-wrap" id="show-content2"></div>
<div class="content-wrap"> 
<?php $this->load->view('qt/footer'); ?>